package com.fulihui.integralbusiness.handler;

import com.fulihui.integral.core.enums.ISAccountType;
import com.fulihui.integral.core.enums.ISChannelType;
import com.fulihui.integral.core.request.ISUserBehaviorReq;
import com.fulihui.integralbusiness.constants.IntegralBusinessFlags;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import java.util.Map;
import java.util.UUID;

/**
 * Created by LM on 2017/4/24.
 */
@Component("readRedIntegralBusinessHandler")
public class ReadRedIntegralBusinessHandler extends AbstractIntegralBusinessHandler {
    private transient final Logger log = LoggerFactory.getLogger(getClass());

    @Override
    public void handle(Map<String, Object> msg) {
        // 积分数量
        Long integral = ((Integer) msg.get("integral")).longValue();
        ISUserBehaviorReq req = new ISUserBehaviorReq();
        req.setAmount(integral);
        req.setOutTradeNo(UUID.randomUUID().toString());
        req.setUserId(msg.get("userId").toString());
        req.setIsChannelType(ISChannelType.READ_RED.getCode());
        req.setIsAccountType(ISAccountType.BASE_JIFEN.getCode());
        userBehaviorService.doAdd(req);
    }

    @Override
    IntegralBusinessFlags getFlag() {
        return IntegralBusinessFlags.READ_RED;
    }
}
